package edu.njust.cma.controller;

import edu.njust.cma.DTO.*;
import edu.njust.cma.config.ConstantConfig;
import edu.njust.cma.pojo.*;
import edu.njust.cma.service.LabStaffService;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;


import java.util.List   ;
/**
 * **实验室人员**
 * 用于查看功能的封装数据的相关结构应该都在pojo里面,都用TaskForLab封装,查看都一个逻辑:
 * 按userid找到相关子任务
 * 按子任务的status和submission的status过滤
 * 填充要发送的数据
 *
 *
 * 用于提交功能接收请求体的结构都以submitFor前缀开头,放在pojo里面,也是一个逻辑:
 * 初次提交就把数据拆开,更新数据库
 * 新建submission
 * 再次提交只是在新建submission之前把之前的submission设置为丢弃
 */

@RestController
@RequestMapping("/labStaff")
public class LabStaffController {
    /**
     * **实验室人员**
     *
     * 1.查看自己的未提交任务
     * 2.查看自己的待审核任务
     * 3.查看自己的已审核未查看的任务
     * 4.查看自己的已经完成的任务
     * 5.提交人员的任务
     * 6.提交设施的任务
     * 7.提交比对的任务
     * 8.提交检验的任务
     * 9.提交样品任务
     * 10.提交模拟任务
     * 11.提交额外要求的任务
     */

    @GetMapping("/test")
    public Result test(){
        return Result.success(labStaffService.getSubTaskForExtra(0));
    }

    /**
     * 1.查看自己的未提交任务
     * @param userId
     * @return
     */
    @GetMapping("/getUnSubmittedTask/{userId}")
    public Result getUnSubmittedTask(@PathVariable("userId") int userId){
        return Result.success(labStaffService.getUnSubmittedTask(userId));
    }

    /**
     * 2.查看自己的待审核任务
     * @param userId
     * @return
     */
    @GetMapping("/getUnReviewedTask/{userId}")
    public Result getUnReviewedTask(@PathVariable("userId") int userId){
        return Result.success(labStaffService.getUnReviewedTask(userId));
    }

    /**
     * 3.查看自己的已审核未查看的任务
     * @param userId
     * @return
     */
    @GetMapping("/getUnCheckedTask/{userId}")
    public Result getUnCheckedTask(@PathVariable("userId") int userId){
        return Result.success(labStaffService.getUnCheckedTask(userId));
    }

    /**
     * 4.查看自己的已经完成的任务
     * @param userId
     * @return
     */
    @GetMapping("/getFinishSubTaskForLab/{userId}")
    public Result getFinishSubTaskForLab(@PathVariable("userId") int userId){
        return Result.success(labStaffService.getFinishSubTaskForLab(userId));
    }

    /**
     * 5.提交人员的任务
     * @param submitForStaff
     * @return
     */
    @PostMapping("/submitForStaff")
    public Result submitForStaff(@RequestBody SubmitForStaff submitForStaff){
        labStaffService.submitForStaff(submitForStaff) ;
        return Result.success();
    }
    /**
     * 5.重新提交人员任务
     * @param submitForStaff
     * @return
     */
    @PostMapping("/submitForStaff/again")
    public Result submitForStaffAgain(@RequestBody SubmitForStaff submitForStaff){
        labStaffService.submitForStaffAgain(submitForStaff);
        return Result.success();
    }

    /**
     * 6.提交设施的任务
     * @param submitForFacilities
     * @return
     */
    @PostMapping("/submitForFacilities")
    public Result submitForFacilities(@RequestBody SubmitForFacilities submitForFacilities){
        labStaffService.submitForFacilities(submitForFacilities);
        return Result.success();
    }
    /**
     * 6.重新提交设施任务
     * @param submitForFacilities
     * @return
     */
    @PostMapping("/submitForFacilities/again")
    public Result submitForFacilitiesAgain(@RequestBody SubmitForFacilities submitForFacilities){
        labStaffService.submitForFacilitiesAgain(submitForFacilities);
        return Result.success();
    }

    /**
     * 7.提交比对的任务
     * @param submitForCompare
     * @return
     */
    @PostMapping("/submitForCompare")
    public Result submitForCompare(@RequestBody SubmitForFacilities submitForCompare){
        labStaffService.submitForCompare(submitForCompare);
        return Result.success();
    }

    /**
     * 7.1重新提交比对任务
     * @param submitForFacilities
     * @return
     */
    @PostMapping("/submitForCompare/again")
    public Result submitForCompareAgain(@RequestBody SubmitForFacilities submitForFacilities){
        labStaffService.submitForCompareAgain(submitForFacilities);
        return Result.success();
    }

    /**
     * 8.提交检验的任务
     * @param submitForInspect
     * @return
     */
    @PostMapping("/submitForInspect")
    public Result submitForInspect(@RequestBody SubmitForFacilities submitForInspect){
        labStaffService.submitForInspect(submitForInspect);
        return Result.success();
    }

    /**
     * 8.重新提交检验任务
     * @param submitForInspect
     * @return
     */
    @PostMapping("/submitForInspect/again")
    public Result submitForInspectAgain(@RequestBody SubmitForFacilities submitForInspect){
        labStaffService.submitForInspectAgain(submitForInspect);
        return Result.success();
    }

    /**
     * 9.提交样品任务
     * @param submitForSample
     * @return
     */
    @PostMapping("/submitForSample")
    public Result submitForSample(@RequestBody SubmitForSample submitForSample){
        labStaffService.submitForSample(submitForSample);
        return Result.success();
    }

    /**
     * 9.提交样品任务
     * @param submitForSample
     * @return
     */
    @PostMapping("/submitForSample/again")
    public Result submitForSampleAgain(@RequestBody SubmitForSample submitForSample){
        labStaffService.submitForSampleAgain(submitForSample);
        return Result.success();
    }

    /**
     * 10.提交模拟任务
     * @param submitForSimulation
     * @return
     */
    @PostMapping("/submitForSimulation")
    public Result submitForSimulation(@RequestBody SubmitForSimulation submitForSimulation){
        labStaffService.submitForSimulation(submitForSimulation);
        return Result.success();
    }

    /**
     * 10.重新提交模拟任务
     * @param submitForSimulation
     * @return
     */
    @PostMapping("/submitForSimulation/again")
    public Result submitForSimulationAgain(@RequestBody SubmitForSimulation submitForSimulation){
        labStaffService.submitForSimulationAgain(submitForSimulation);
        return Result.success();
    }

    /**
     * 11.提交额外要求的任务
     * @param submitForExtra
     * @return
     */
    @PostMapping("/submitForExtra")
    public Result submitForExtra(@RequestBody SubmitForExtra submitForExtra){
        labStaffService.submitForExtra(submitForExtra);
        return Result.success();
    }

    /**
     * 11.重新提交额外要求的任务
     * @param submitForExtra
     * @return
     */
    @PostMapping("/submitForExtra/again")
    public Result submitForExtraAgain(@RequestBody SubmitForExtra submitForExtra){
        labStaffService.submitForExtraAgain(submitForExtra);
        return Result.success();
    }

    /**
     * 修改 Submission
     */
    @GetMapping("/readSubmission/{submissionId}")
    public Result readSubmission(@PathVariable("submissionId") int submissionId){
        System.out.println("nb");
        labStaffService.readSubmission(submissionId);
        return Result.success();
    }
    @Autowired
    LabStaffService labStaffService;
}
